﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ATM.Commons
{
    public class Untilities
    {
        public string CreatRandomCardID()
        {
            Random rd = new Random();
            int intResult = rd.Next(0, 9999);
            string strCardNumber=intResult.ToString();
            if(intResult <1000 && intResult >999)
            {
                strCardNumber = "0" + intResult.ToString();
            }
            if (intResult < 100 && intResult > 10)
            {
                strCardNumber = "00" + intResult.ToString();
            }
            else if (intResult < 10 && intResult >= 0)
            {
                strCardNumber = "000" + intResult.ToString();
            }
            return strCardNumber;
        }

        public string CreateRandomPINCode()
        {
            Random rd = new Random();
            int intResult = rd.Next(0, 999999);
            string strPIN="";
            if (intResult < 100000 && intResult > 9999)
            {
                strPIN = "0" + intResult.ToString();
            }
            if (intResult < 10000 && intResult > 999)
            {
                strPIN = "00" + intResult.ToString();
            }
            if(intResult <1000 && intResult >99)
            {
                strPIN = "000" + intResult.ToString();
            }
            if (intResult < 100 && intResult > 9)
            {
                strPIN = "0000" + intResult.ToString();
            }
            else if (intResult < 10 && intResult >= 0)
            {
                strPIN = "00000" + intResult.ToString();
            }
            return strPIN;
            
        }
        
        public bool CheckRegexAccountNumber(string strInput)
        {
            string patten = "\\d+";
            Match match = Regex.Match(strInput,patten);
            if (match.Success)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        
    }
}
